home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / WORDMISC / BANNER.LZH / FSY.ASM < prev    next >
Assembly Source File  |  1986-09-06  |  14KB  |  493 lines

  1. COMMENT ;
  2.  
  3.     FSY.ASM The assembly language routines for the
  4.     FONTSY banner printer.  The main program is written
  5.     for the Microsoft QuickBASIC compiler.  8/25/86
  6.     (C) Copyright 1985, 1986 Merlin R. Null
  7.  
  8. ;
  9. DATA        SEGMENT    BYTE    PUBLIC    'DATA'
  10.  
  11. NO    EQU    0
  12. YES    EQU    NOT NO
  13.  
  14. ;Set to YES if you are going to use a snowy color card
  15.  
  16. No_Snow        EQU    YES
  17.  
  18. ;-----------------------------------------------------------------
  19. ; 0 BLACK    4 RED          8 GRAY        12 LIGHT RED
  20. ; 1 BLUE    5 MAGENTA     9 LIGHT BLUE    13 LIGHT MAGENTA
  21. ; 2 GREEN    6 BROWN         10 LIGHT GREEN    14 YELLOW
  22. ; 3 CYAN    7 WHITE         11 LIGHT CYAN    15 HIGH-INTENSITY WHITE
  23.  
  24. ;                    Location Used
  25. GreenOnBlack    EQU    0AH        ;most text
  26. RedOnBlue    EQU    1CH        ;option 4
  27. YellowOnBlue    EQU    1EH        ;main title
  28. WhiteOnGreen    EQU    2FH        ;option 2
  29. WhiteOnCyan    EQU    3FH        ;option menu
  30. WhiteOnRed    EQU    4FH        ;loading font
  31. WhiteOnMagenta    EQU    5FH        ;option 3
  32.  
  33. ;-----------------------------------------------------------------
  34. Mono_SegAddr    EQU    0B000H        ;address of monochrome buffer
  35. Graph_SegAdr    EQU    0B800H        ;address of graphics buffer
  36.  
  37. TitleMes    DB    ' ╔',76 DUP (205),'╗ '
  38.         DB    ' ║   FONTSY  version 2.1   9/6/86  (C) Copyright '
  39.         DB    '1985, 1986  Merlin R. Null   ║ '
  40.         DB    ' ╚',76 DUP (205),'╝ ',0
  41.  
  42. Fontin1        DB    'Prints banners using fonts created by FONTCODE'
  43.         DB    30,6,1,1,1,1
  44.                DB    'Enter the name of the font you wish to use'
  45.         DB    30,2,1,1,1
  46.                DB    'Examples:',4,'KIWI',6,'Use the font named KIWI.FNT'
  47.         DB    30,13
  48.         DB    'A:',8,'List of fonts on drive A:',30,15
  49.         DB    '\FNTS\',4,'List of fonts on subdirectory',0
  50.  
  51. FontPromptDat    DB    'Font name, Drive or Path ?',0
  52.  
  53. FrameDat    DB    ' ╔',27 DUP (205),'╗ ',30,19
  54.         DB    ' ║  ',23,'  ║ ',30,19
  55.         DB    ' ╚',27 DUP (205),'╝ ',0
  56.  
  57. LoadFontMes    DB    '     Loading Font      ',0
  58.  
  59. AvailText    DB    'Available characters are:',0
  60. BannerPrompt    DB    '<Return> for options, ^C to exit',26,1,1,1
  61.         DB    'Banner text ?',0
  62.  
  63. OptMenuTitle    DB    '     Font Options      ',0
  64.  
  65. MenuDat        DB    '1  Change fonts',23,'is:',30,9,1
  66.         DB    '2  Set column to start printing',7,'is:'
  67.         DB    30,9,1
  68.         DB    '3  Set print character',16,'is:',30,9,1
  69.         DB    '4  Set banner spacing',17,'is:',30,9,1
  70.         DB    '5  Toggle character width',13,'is:',30,9,1
  71.         DB    '6  Toggle character height',12,'is:',30,9,1
  72.         DB    '7  Printer initialization string',30,18,1
  73.         DB    '8  Save changes to disk',30,27,1
  74.         DB    '<Return> Enter banner text',30,15,1,1
  75.         DB    'Option or <Return> ?',0
  76.  
  77. Option2Title    DB    '      Left Margin      ',0
  78. Option2Dat    DB    'Printing now starts at column',29,1,1,1,12
  79.         DB    'Set the left margin to center a banner or allow two'
  80.         DB    29,1
  81.         DB    'lines of a smaller font.  Allow room for descenders.'
  82.         DB    30,6,1,1,1
  83.         DB    '<Return> retains the current value',25,1,1,1,1
  84.         DB    'Column to start printing (1-230) ?',0
  85.  
  86. Option3Title    DB    '    Print Character    ',0
  87. Option3Dat    DB    'Current print character:',30,11,1,1
  88.         DB    'The single character used by  FONTSY to print all '
  89.         DB    'large letters can',13,1
  90.         DB    'be set to any printable character.  Use a single '
  91.         DB    'keystroke OR enter',13,1
  92.         DB    'a minimum of two decimal numbers to use the ASCII '
  93.         DB    'value.   Example:',13,1
  94.         DB    'Character 239 on the Gemini-10X is a 6 by 6 graphic '
  95.         DB    'square.   Enter',13,1
  96.         DB    '255 to print each large character with its'
  97.         DB    ' own small character.',31,1,1
  98.         DB    '<Return> retains the current value',26,1,1,1
  99.         DB    'Character or decimal value ?',0
  100.  
  101. Option4Title    DB    'Rows Between Characters',0
  102. Option4Dat    DB    'Current value:',30,1,1,1,12
  103.         DB    'The number of rows between large characters may be '
  104.         DB    'set from 0 to 99',7,1,1,1,22
  105.         DB    '<Return> retains the current value'
  106.         DB    24,1,1,1,1,1,1
  107.         DB    'Number of rows ?',0
  108.  
  109. Option7Title    DB    'Printer Initialiaztion ',0
  110. Option7Dat    DB    'An initialization string may be optionally sent to '
  111.         DB    'the printer',18
  112.         DB    'to set pitch, linefeeds or other funtions.  This may'
  113.         DB    ' be set to',18
  114.         DB    'different values for each font.  Please consult your'
  115.         DB    ' printer',20
  116.         DB    'manual for exact details.  Enter a bare return for '
  117.         DB    'no change,',19
  118.         DB    '999 for no initialization string.',0
  119.  
  120. Option7aTitle    DB    ' Printer Reset String  ',0
  121. Option7aDat    DB    'A printer reset string should be sent to set printer'
  122.         DB    ' back to',20
  123.         DB    'defaults.  It is preferable to reset all functions '
  124.         DB    'set with',21
  125.         DB    'the initialization string rather than use a command '
  126.         DB    'to reset',20
  127.         DB    'everything.',0
  128.  
  129. Option7bDat    DB    'Enter each byte of the printer command string with '
  130.         DB    'the decimal',18
  131.         DB    'value of each character.  Terminate input with a '
  132.         DB    'bare <Return>',0
  133.  
  134. Option8Title    DB    ' Save the Current Font ',0
  135.  
  136. Display_Table    DB    2DH,29H            ;display re-enable values for
  137.                         ; modes 2 and 3
  138. Display_Mode    DW    0            ;current crt display mode
  139. AtrByte        DB    0
  140.  
  141. DATA        ENDS
  142.  
  143. DGROUP        GROUP    DATA
  144.  
  145. CODE        SEGMENT    BYTE    PUBLIC    'CODE'
  146.         ASSUME    CS:CODE, DS:DGROUP
  147.  
  148.         PUBLIC    FontScr,FontPrompt,DoTitle,LoadingFont,OptionMenu
  149.         PUBLIC    GetBanner,OptionScr2,OptionScr3,OptionScr4
  150.         PUBLIC    OptionScr7,OptionScr7a,OptionScr7b,OptionScr8
  151.         PUBLIC    WindowScroll
  152.  
  153. Main        PROC    FAR
  154. ;--------------------------------------------------------------------
  155. DoTitle:    PUSH    BP
  156.         MOV    BP,SP
  157.         CALL    ClrScr
  158.         MOV    AtrByte,YellowOnBlue
  159.         LEA    SI,TitleMes
  160.         XOR    DX,DX            ;row 0 column 0
  161.         CALL    IsrtStr
  162.         POP    BP
  163.         RET
  164. ;--------------------------------------------------------------------
  165. FontScr:    PUSH    BP
  166.         MOV    BP,SP
  167.         MOV    AtrByte,GreenOnBlack
  168.         LEA    SI,FontIn1
  169.         MOV    DX,030FH        ;row 3 column 15
  170.         CALL    ISRTSTR
  171.         POP    BP
  172.         RET
  173. ;--------------------------------------------------------------------
  174. FontPrompt:    PUSH    BP
  175.         MOV    BP,SP
  176.         MOV    AtrByte,GreenOnBlack
  177.         LEA    SI,FontPromptDat
  178.         MOV    DX,1700H        ;row 23 column 0
  179.         CALL    ISRTSTR
  180.         POP    BP
  181.         RET
  182. ;--------------------------------------------------------------------
  183. LoadingFont:    PUSH    BP
  184.         MOV    BP,SP
  185.         MOV    AtrByte,WhiteOnRed
  186.         LEA    SI,FrameDat
  187.         MOV    DX,0A17H        ;row 10 column 23
  188.         CALL    IsrtStr
  189.         LEA    SI,LoadFontMes
  190.         MOV    DX,0B1BH        ;row 11 column 27
  191.         CALL    IsrtStr
  192.         POP    BP
  193.         RET
  194. ;--------------------------------------------------------------------
  195. GetBanner:    PUSH    BP
  196.         MOV    BP,SP
  197.         MOV    AtrByte,GreenOnBlack
  198.         LEA    SI,AvailText
  199.         MOV    DX,091AH        ;row 9 column 26
  200.         CALL    IsrtStr
  201.         LEA    SI,BannerPrompt
  202.         MOV    DX,1216H        ;row 18 column 22
  203.         CALL    ISRTSTR
  204.         POP    BP
  205.         RET
  206. ;--------------------------------------------------------------------
  207. OptionMenu:    PUSH    BP
  208.         MOV    BP,SP
  209.         CALL    ClrScr
  210.         MOV    ATRBYTE,WhiteOnCyan
  211.         LEA    SI,FrameDat
  212.         MOV    DX,0017H        ;row 0 column 23
  213.         CALL    IsrtStr
  214.         LEA    SI,OptMenuTitle
  215.         MOV    DX,011BH        ;row 1 column 27
  216.         CALL    IsrtStr
  217.         MOV    AtrByte,GreenOnBlack
  218.         LEA    SI,MenuDat
  219.         MOV    DX,0409H        ;row 4 column 9
  220.         CALL    IsrtStr
  221.         POP    BP
  222.         RET
  223. ;--------------------------------------------------------------------
  224. OptionScr2:    PUSH    BP
  225.         MOV    BP,SP
  226.         CALL    ClrScr
  227.         MOV    AtrByte,WhiteOnGreen
  228.         LEA    SI,FrameDat
  229.         MOV    DX,0017H        ;row 0 column 23
  230.         CALL    IsrtStr
  231.         LEA    SI,Option2Title
  232.         MOV    DX,011BH        ;row 1 column 27
  233.         CALL    IsrtStr
  234.         MOV    AtrByte,GreenOnBlack
  235.         LEA    SI,Option2Dat
  236.         MOV    DX,0717H        ;row 7 column 23
  237.         CALL    IsrtStr
  238.         POP    BP
  239.         RET
  240. ;--------------------------------------------------------------------
  241. OptionScr3:    PUSH    BP
  242.         MOV    BP,SP
  243.         CALL    ClrScr
  244.         MOV    AtrByte,WhiteOnMagenta
  245.         LEA    SI,FrameDat
  246.         MOV    DX,0017H        ;row 0 column 23
  247.         CALL    IsrtStr
  248.         LEA    SI,Option3Title
  249.         MOV    DX,011BH        ;row 1 column 27
  250.         CALL    IsrtStr
  251.         MOV    AtrByte,GreenOnBlack
  252.         LEA    SI,Option3Dat
  253.         MOV    DX,0515H        ;row 5 column 21
  254.         CALL    IsrtStr
  255.         POP    BP
  256.         RET
  257. ;--------------------------------------------------------------------
  258. OptionScr4:    PUSH    BP
  259.         MOV    BP,SP
  260.         CALL    ClrScr
  261.         MOV    AtrByte,RedOnBlue
  262.         LEA    SI,FrameDat
  263.         MOV    DX,0017H        ;row 0 column 23
  264.         CALL    IsrtStr
  265.         LEA    SI,Option4Title
  266.         MOV    DX,011BH        ;row 1 column 27
  267.         CALL    IsrtStr
  268.         MOV    AtrByte,GreenOnBlack
  269.         LEA    SI,Option4Dat
  270.         MOV    DX,081EH        ;row 8 column 30
  271.         CALL    IsrtStr
  272.         POP    BP
  273.         RET
  274. ;--------------------------------------------------------------------
  275. OptionScr7:    PUSH    BP
  276.         MOV    BP,SP
  277.         CALL    ClrScr
  278.         MOV    AtrByte,WhiteOnCyan
  279.         LEA    SI,FrameDat
  280.         MOV    DX,0017H        ;row 0 column 23
  281.         CALL    IsrtStr
  282.         LEA    SI,Option7Title
  283.         MOV    DX,011BH        ;row 1 column 27
  284.         CALL    IsrtStr
  285.         MOV    AtrByte,GreenOnBlack
  286.         LEA    SI,Option7Dat
  287.         MOV    DX,0508H        ;row 5 column 8
  288.         CALL    IsrtStr
  289.         POP    BP
  290.         RET
  291. ;--------------------------------------------------------------------
  292. OptionScr7a:    PUSH    BP
  293.         MOV    BP,SP
  294.         CALL    ClrScr
  295.         MOV    AtrByte,WhiteOnMagenta
  296.         LEA    SI,FrameDat
  297.         MOV    DX,0017H        ;row 0 column 23
  298.         CALL    IsrtStr
  299.         LEA    SI,Option7aTitle
  300.         MOV    DX,011BH        ;row 1 column 27
  301.         CALL    IsrtStr
  302.         MOV    AtrByte,GreenOnBlack
  303.         LEA    SI,Option7aDat
  304.         MOV    DX,0508H        ;row 5 column 8
  305.         CALL    IsrtStr
  306.         POP    BP
  307.         RET
  308. ;--------------------------------------------------------------------
  309. OptionScr7b:    PUSH    BP
  310.         MOV    BP,SP
  311.         LEA    SI,Option7bDat
  312.         MOV    DX,0B08H        ;row 5 column 8
  313.         CALL    IsrtStr
  314.         POP    BP
  315.         RET
  316. ;--------------------------------------------------------------------
  317. OptionScr8:    PUSH    BP
  318.         MOV    BP,SP
  319.         CALL    ClrScr
  320.         MOV    AtrByte,WhiteOnGreen
  321.         LEA    SI,FrameDat
  322.         MOV    DX,0017H        ;row 0 column 23
  323.         CALL    IsrtStr
  324.         LEA    SI,Option8Title
  325.         MOV    DX,011BH        ;row 1 column 27
  326.         CALL    IsrtStr
  327.         POP    BP
  328.         RET
  329. ;--------------------------------------------------------------------
  330. ;Scroll Window area. Called from BASIC with ULCorner which is put
  331. ;in CX and LRCorner to DX
  332.  
  333. WindowScroll:    PUSH    BP
  334.         MOV    BP,SP
  335.         MOV    BX,[BP]+8    ;upper left
  336.         MOV    CX,[BX]
  337.         MOV    BX,[BP]+6    ;lower right
  338.         MOV    DX,[BX]
  339.         MOV    BH,7        ;normal screen attribute
  340.         MOV    AX,0601H    ;scroll active window 1 line
  341.         INT    10H        ;call BIOS
  342.         POP    BP
  343.         RET    4
  344. ;--------------------------------------------------------------------
  345. Main        ENDP
  346.  
  347. ;********************************************************************
  348. ;******** Start of Subroutines Local to the Assembler Module ********
  349. ;********************************************************************
  350. ;Clear the Screen and Home
  351.  
  352. ClrScr        PROC    NEAR
  353.         MOV    CX,0        ;upper left
  354.         MOV    DX,184FH    ;lower right
  355.         MOV    AX,0600H    ;scroll active page
  356.         MOV    BH,7        ;normal screen attribute
  357.         INT    10H        ;call BIOS
  358.         MOV    DX,0        ;row 0, column 0
  359.                     ;fall through to LOCATE
  360. ClrScr        ENDP
  361. ;--------------------------------------------------------------------
  362. ;Direct Cursor Addressing
  363.  
  364. Locate        PROC    NEAR
  365.         PUSH    BX
  366.         MOV    AH,2        ;request move cursor
  367.         MOV    BH,0        ;page #0
  368.         INT    10H        ;call BIOS
  369.         POP    BX
  370.         RET
  371. Locate        ENDP
  372. ;--------------------------------------------------------------------
  373. ;Insert String Directly in the Video Buffer
  374.  
  375. IsrtStr        PROC    NEAR
  376.         PUSH    ES
  377.     IF    No_Snow
  378.         CALL    Video_Disable    ;turn display off for
  379.                     ; snow-free writing
  380.     ENDIF
  381.         CALL    Calc_Vid_Offset    ;calc offset into video buffer
  382.         MOV    DI,AX        ;offset was returned in AX
  383.         MOV    DH,AtrByte    ;get the attribute byte
  384.         CALL    Set_Vid_Addr    ;set the monochrome or graphics
  385.         MOV    ES,AX        ;video buffer address into ES
  386.  
  387. Isrt_Loop:    MOV    DL,BYTE PTR[SI]
  388.         CMP    DL,0
  389.         JE    IsrtStr_EXIT    ;exit if end of string
  390.         CMP    DL,31        ;control character?
  391.         JA    Isrt_Word    ;no, use the character
  392.         CMP    DL,1
  393.         JZ    SKIP_80
  394.         XOR    DH,DH
  395.         ADD    DI,DX        ;yes, move pointer ahead
  396.         ADD    DI,DX        ;2 X ASCII of character
  397.         MOV    DH,AtrByte    ;restore attribute byte
  398.         JMP    SHORT Nxt_Byte
  399.  
  400. Skip_80:    ADD    DI,0A0H        ;skip next 80 positions
  401.         JMP    SHORT Nxt_Byte
  402.  
  403. Isrt_Word:    MOV    ES:WORD PTR[DI],DX  ;move char and attr to crt buf
  404.  
  405.         ADD    DI,2        ;point to next crt buf loc
  406. NXT_BYTE:    ADD    SI,1        ;point to next string byte
  407.         JMP    SHORT ISRT_LOOP    ;move another word
  408.  
  409. IsrtStr_EXIT:
  410.     IF    No_Snow
  411.         CALL    Video_Enable    ;video back on if CGA
  412.     ENDIF
  413.         POP    ES
  414.         RET
  415. IsrtStr        ENDP
  416. ;--------------------------------------------------------------------
  417. ;Set Video Address
  418.  
  419. Set_Vid_Addr    PROC    NEAR
  420.         CALL    Get_Mode    ;get crt mode
  421.         CMP    AL,7        ;is it monochrome
  422.         JNE    Its_Graphics
  423.         MOV    AX,Mono_Segaddr    ;monochrome buffer seg addr
  424.         RET
  425.  
  426. Its_Graphics:    MOV    AX,Graph_Segadr    ;graphics buffer seg address
  427.         RET
  428. Set_Vid_Addr    ENDP
  429.  
  430. ;--------------------------------------------------------------------
  431. ;Calculate Video Address
  432.  
  433. Calc_Vid_Offset    PROC    NEAR
  434.         MOV    AX,160        ;number of bytes in row
  435.         MUL    DH        ;row * 160
  436.         SHL    DL,1        ;column * 2
  437.         XOR    DH,DH        ;byte to word
  438.         ADD    AX,DX        ;(row *160)+(column*2)
  439.         MOV    DI,AX        ;set offset in DI
  440.         RET
  441. Calc_Vid_Offset    ENDP
  442. ;--------------------------------------------------------------------
  443. ;Get Video Mode.
  444. ;Returns CRT mode in AL and the number of character columns on the
  445. ;screen in AH.
  446.  
  447. Get_Mode    PROC    NEAR
  448.         MOV    AH,0FH
  449.         INT    10H
  450.         RET
  451. Get_Mode    ENDP
  452. ;---------------------------------------------------------------------------
  453. ;VIDEO_ENABLE and VIDEO_DISABLE routines manipulate bit 3 of port 3D8h,
  454. ;the CGA Mode Control Register, to temporarily turn the display on or off.
  455. ;These routines write directly to hardware, and have no effect on other
  456. ;video adapters.
  457.  
  458.     IF    No_Snow
  459. Video_Disable    PROC    NEAR
  460.         PUSH    DX
  461.         CALL    Get_Mode    ;get crt mode
  462.         CMP    AL,7        ;is it monochrome
  463.         JE    Disable2
  464.         MOV    DX,3DAH        ;read CGA status port
  465. Disable1:    IN    AL,DX        ;wait for vertical retrace to
  466.                     ;occur
  467.         TEST    AL,8        ;is bit 3 set?
  468.         JE    Disable1    ;no, wait until it is
  469.         MOV    DX,3D8H        ;now disable the display
  470.         MOV    AL,25H        ;by clearing bit 3 of the Mode
  471.                     ; Control Register
  472.         OUT    DX,AL
  473. Disable2:    POP    DX
  474.         RET
  475. Video_Disable    ENDP
  476. ;---------------------------------------------------------------------------
  477. Video_Enable    PROC    NEAR
  478.         CALL    Get_Mode    ;get crt mode
  479.         CMP    AL,7        ;is it monochrome
  480.         JE    Enable2
  481.         XOR    AH,AH        ;eliminate columns info
  482.         MOV    DX,3D8H        ;CGA Mode Control Register
  483.         MOV    BX,AX        ;video mode to BX
  484.         SUB    BX,2
  485.         MOV    AL,Display_Table[BX]
  486.         OUT    DX,AL        ;and send it to the port
  487. Enable2:    RET
  488. Video_Enable    ENDP
  489.     ENDIF
  490.  
  491. CODE        ENDS
  492.         END
  493.